Elementi Fondamentali dell'Ingegneria dei Prompt
Ingegneria dei Prompt (PE) è il processo di progettazione e ottimizzazione degli input testuali per guidare i Modelli Linguistici di Grande Dimensione (LLM) verso risultati di alta qualità e coerenti.
1. Definizione dell'Interfaccia
Che cosa: Rappresenta l'interfaccia principale di "programmazione" per l'intelligenza artificiale generativa.
Perché: Trasforma l'interazione da una previsione grezza e imprevedibile del testo a un'esecuzione intenzionale e strutturata di istruzioni.
2. Fondamenti dei Modelli
- Modelli Base LLM: Addestrati semplicemente a prevedere il token successivo in base alle relazioni statistiche in grandi insiemi di dati, massimizzando la probabilitĂ $P(w_t | w_1, w_2, ..., w_{t-1})$.
- Modelli LLM Adattati all'Istruzione: Affinati tramite Apprendimento per Rinforzo con Feedback Umano (RLHF) per seguire esplicitamente direzioni specifiche e agire come assistenti utili.
3. Anatomia di un Prompt Efficace
Come: Un prompt solido contiene di solito:
- Istruzione: L'azione specifica richiesta.
- Contenuto Principale: I dati target da elaborare.
- Contenuto Secondario: Parametri, formattazione o vincoli (per affrontare la stocasticitĂ e le allucinazioni).
La RealtĂ della Tokenizzazione
I modelli non leggono parole; essi elaborano token—unità più piccole di sequenze di testo utilizzate per calcolare probabilità statistiche.
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
Question 1
What is the primary difference between a Base LLM and an Instruction-Tuned LLM?
Question 2
Why is the use of delimiters (like triple backticks or hashes) considered a best practice in prompt engineering?
Challenge: Tutor AI Constraints
Refining prompts for educational safety.
You are building a tutor-style AI for a startup. The model is currently giving away answers too quickly and sometimes making up facts when it doesn't know the answer.
Task 1
Implement "Chain-of-thought" prompting in the system message to prevent the AI from giving away answers immediately.
Solution:
Instruct the model to:
Instruct the model to:
"Work through the problem step-by-step before providing the final answer. Do not reveal the final answer until the student has attempted the steps."Task 2
Apply an "out" to prevent fabrications (hallucinations) when the AI doesn't know the answer.
Solution:
Add the explicit instruction:
Add the explicit instruction:
"If you do not know the answer based on the provided text or standard curriculum, state clearly that you do not know."